<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>监控中心 - 标签管理</title>

    <!-- Bootstrap Core CSS -->
    <link href="${request.getContextPath()}/public/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="${request.getContextPath()}/public/dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="${request.getContextPath()}/public/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <!--嵌入头部跟菜单-->
        <#include "/admin/inc/menu.html"/>

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-10">
                        <h4 class="page-header">RFID列表 —— 仓库名称：${warehouse.name}</h4>
                    </div>
                    <!-- /.col-lg-12 -->
                    <div class="col-lg-2">
                        <a href="#" class="btn btn-primary page-header" data-toggle="modal" data-target="#myModal"> <li class="fa fa-plus"></li>  新增RFID</a>
                    </div>
                </div>
        <!-- /.row -->
        <div class="row">

            <div class="col-lg-12">

                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>标签编号</th>
                                    <th>关联仓单</th>
                                    <th>关联摄像头</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>

                                <#if tagList??>
                                    <#list tagList as tag>
                                    <tr>
                                        <td>${tag.no}</td>
                                        <td> <#if tag.receipt??> <a href="${request.getContextPath()}/admin/receipt/update.do?whId=${tag.warehouse.id}&repNo=${tag.receipt.no}">${tag.receipt.no}</a> </#if></td>
                                        <td> <#if tag.camera??> <a href="${request.getContextPath()}/admin/camera/update.do?whId=${tag.warehouse.id}&cameraId=${tag.camera.id}"> ${tag.camera.name}</a></#if></td>
                                        <td> <#if !tag.receipt?? && !tag.camera?? > <button class="btn btn-primary" onclick="delTag('${tag.no}');">删除</button> </#if></td>
                                    </tr>
                                    </#list>
                                </#if>

                            </tbody>
                        </table>
                    </div>
                    <!-- /.table-responsive -->
                </div>

            </div>

        </div>
        <!-- /.row -->
                
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->


    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">新增RFID</h4>
                </div>
                <div class="modal-body">

                    <div class="form-group input-group">
                        <span class="input-group-addon">RFID编号</span>
                        <input id="tag_id" type="text" class="form-control" placeholder="请输入RFID编号">
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="addTag();">提交</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>



    <!-- jQuery -->
    <script src="${request.getContextPath()}/public/vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="${request.getContextPath()}/public/vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="${request.getContextPath()}/public/dist/js/sb-admin-2.js"></script>


    <script>

        //删除标签
        function delTag(no){

            if(confirm("是否确认删除该RDFID？")){

                var url="${request.getContextPath()}/admin/tag/del.do";

                $.post(url,{no:no},function(data){

                    alert(data.msg);

                    location.reload();

                },"json");
            }
        }


        //新增标签
        function addTag(){

            var no = $("#tag_id").val();

            if(no==null){

                alert("请输入RFID编号");

                return;
            }

            var url="${request.getContextPath()}/admin/tag/add.do";

            //提交新增请求
            $.post(url,{no:no,whId:'${warehouse.id}'},function(data){

                alert(data.msg);

                location.reload();

            },"json");
        }

    </script>



</body>

</html>
